package com.google.shoopinggoods.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.shoopinggoods.ui.StateLayout;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/10/13.
 */
public abstract class BaseFragment extends Fragment implements StateLayout.OnReloadListener{

    public StateLayout stateLayout;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (stateLayout ==null){
            stateLayout = new StateLayout(getContext());
            View contentView = inflater.inflate(getLayoutId(), null);
            stateLayout.setContentView(contentView);
            stateLayout.showLoadingView();//默认显示加载页面
            stateLayout.setOnReloadListener(this);
            ButterKnife.bind(this,contentView);
            setListener();
            init();
            loadData();
        }
        return stateLayout;

    }


    @Override
    public void onReload() {

    }

    public abstract int getLayoutId();

    public abstract void setListener();

    public void init(){

    }

    public abstract void loadData();

}
